package com.baizhi.springboot.controller;

import com.baizhi.springboot.entity.Evection;
import com.baizhi.springboot.entity.Income;
import com.baizhi.springboot.entity.Leave;
import com.baizhi.springboot.entity.Schedule;
import com.baizhi.springboot.service.PersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class PersonnelController {
    @Autowired
    private PersonnelService personnelService;
    @RequestMapping("/insertLeave")
    public Map insertLeave(Leave leave) {

        HashMap<Object, Object> map = new HashMap<>();

        try {
            personnelService.insertLeave(leave);
            map.put("isAdd", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("isAdd", false);
        }
        return map;
    }

    @RequestMapping("/insertEvection")
    public Map insertEvection(Evection evection) {

        HashMap<Object, Object> map = new HashMap<>();

        try {
            personnelService.insertEvection(evection);
            map.put("isAdd", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("isAdd", false);
        }
        return map;
    }
    @RequestMapping("/insertIncome")
    public Map insertIncome(Income income) {

        HashMap<Object, Object> map = new HashMap<>();

        try {
            personnelService.insertIncome(income);
            map.put("isAdd", true);
        } catch (Exception e) {
            e.printStackTrace();
            map.put("isAdd", false);
        }
        return map;
    }
}
